<script>
function checkdata() {
	reg=/^\d+$/;   
	if(reg.test($('#en_title').val())){ 
		showMsg('英文名称不允许有数字！');
		return false;
	}
}
</script>
       	<div class="ContentWp">
        	<div class="ContentThemeWp">
             <div class="Ibx_Main_Wp">
             <div class="Ibx_Lst_dWp dWpOpen">
           	   <h4 class="Ibx_Lst_dTT" action="list"><span class="Txt"><span >网站类别管理</span></span></h4>
                <table width="550" cellpadding="15" cellspacing="15" style="border-spacing:15px; border-collapse:separate;">
                <tr>
                  <td></td>
                  <td>属于类别</td>
                  <td>
                 
                  <select name="parent" class="Ipt">
                  	<option value="0">一级类别</option>
                     <?php 
					 if(!empty($channel)) {
						 foreach($channel as $k=>$v) {
							 $depth = "";
							 for($i = 0; $i < $v['depth']; $i++) {
								 $depth .= '﹣';
							 }
							 echo "<option value='".$v['cid'] .'-'.$v['depth'].'-'.$v['channel'].'-'.$v['orders']."'>".$depth.$v['title']. '(' . $v['en_title'] . ')' . "</option>";
						 }
					 }
				     ?>
                  </select></td>
                  <td></td>
                </tr>
                <tr><td width="29"></td>
                  <td width="81">类别名称</td><td width="75"><input type="text" value="" name="title" class="Ipt"></td>
                  <td width="235">&nbsp;</td>
                </tr>
                <tr>
                  <td></td>
                  <td>英文名称</td>
                  <td><input type="text" value="" name="en_title" id="en_title" class="Ipt"></td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td></td>
                  <td>受否显示</td>
                  <td><input type="checkbox" value="1" name="display" checked class="Ipt"></td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td></td>
                  <td>外部URL</td>
                  <td><input type="text" value="" name="out_url" class="Ipt"></td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td></td>
                  <td>&nbsp;</td>
                  <td><input name="" type="submit" value="确定添加" class="Btn BtnNml ImpBtn">
                  <input name="__H" type="hidden" value="addChannel">
                  </td>
                  <td>&nbsp;</td>
                </tr>
                </table>
             </div>
              <div class="Ibx_Lst_dWp dWpOpen">
           	   <h4 class="Ibx_Lst_dTT" action="list"><span class="Txt"><span >类别管理</span></span></h4>
                <table width="550" cellpadding="15" cellspacing="15" style="border-spacing:15px; border-collapse:separate;">
             	<?php 
				if(!empty($channel)) {
					 foreach($channel as $k=>$v) {
						 $depth = "";
						 for($i = 0; $i < $v['depth']; $i++) {
							 $depth .= '﹣';
						 }
						 echo '<tr><td></td><td></td><td>' . $depth.$v['title']. '(' 
						 . $v['en_title'] . ')</td><td><a href="javascript:channelEdit(\'' . $v['title']
						 . '\', \''. $v['en_title'] . '\', \''. $v['display'] . '\', \''. $v['out_url'] . '\', \'' . $v['cid']. '\');">修改</a>|<a href="'.
						 	$this->config->base_url().'manager/channel?delid=">删除</a></td></tr>';
					 }
				}
				?>
               </table>
              </div>
             <h4 class="Ibx_Lst_bExtra" id="oH4Check"></h4>
             <div class="gToolbar gTbrTop">
                <div class="Extra"></div>
             </div>
              </div>
          </div>
        </div>
<script language="javascript">
function channelEdit(title, en_title, display, out_url, cid) {
	var checked = '';
	if(display == 1) checked = 'checked';
	var html = "";
	html += '类别名称：<input id="title" name="" value="'+title+'"  type="text" class="Ipt" />　'
	     + '英文名称：<input id="en_title" name="" value="'+en_title+'"  type="text" class="Ipt" /><br>'
	     + '受否显示：<input id="display" name="" '+checked+' value="1" type="checkbox" class="Ipt" />　'
	     + '外部URL：<input id="out_url" name="" value="'+out_url+'"  type="text" class="Ipt" /><br>'
	     + '<center><input class="Btn BtnNml ImpBtn" name="" value="确定修改" type="button"  onclick="channelEditSend('+cid+')" /> '
	     +'<input class="Btn BtnNml ImpBtn" name="" value="取消修改" type="button" onclick="channelEditClode()" /></center>';
	
	$(".loadingWord").css({'height':'auto'});	
	$('#error_msg').html(html);
	$(".overlay").css({'display':'block','opacity':'0.8'});		
	$(".showbox").stop(true).animate({'margin-top':'300px','opacity':'1'},200);
	
}
function channelEditClode() {
	$(".showbox").stop(true).animate({'margin-top':'-500px','opacity':'0'},400);
	$(".overlay").css({'display':'none','opacity':'0'});	
}
function channelEditSend(cid) {
	var url = "<?php echo $this->config->base_url(); ?>manager/channel";
	var display = 0;
	if($("#display").attr("checked") == true) {display = 1;}
	var __HASH_ = $("input[name='<?php echo $this->config->item('csrf_token_name'); ?>']").val();
	$.post(url, { "__H": "editChannel", "title":$('#title').val(), "en_title":$('#en_title').val(), "out_url":$('#out_url').val(), "display":display, "<?php echo $this->config->item('csrf_token_name'); ?>":__HASH_, "cid":cid },
		function(data){
			if(data.success == 1) {
				showMsg('修改类别成功！正在刷新页面，请稍后.....');
				setTimeout(function(){window.location = url;}, 1500);
			}
	}, "json");
}
</script>
